/**
 * Created by syt on 2016/5/19.
 */

//java 凯撒密码
    import java.io.*;
    import java.util.Scanner;


    public class kaisa {
        public static void main(String[] args) {
            System.out.print("请输入密钥：  ");
            Scanner s = new Scanner(System.in);
            int a = s.nextInt();
            C(a);
        }


        public static void C(int n) {
            try {
                char b[];
                BufferedReader br2 = new BufferedReader(new
                        InputStreamReader(System.in));
                System.out.println("请输入一段明文：   ");
                String str2 = br2.readLine();
                b = str2.toCharArray();
                System.out.println("密文为：   ");
                int k = n;
                for (int i = 0; i < str2.length(); i++) {
                    char ch = (char) ((b[i] - 'a' + k) % 26 + 'a');
                    System.out.print(ch);
                }
                System.out.println("密钥k = " + k);

            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
        }

    }


